//Jonathan Flessner
//27-April-2014
//cardTest for outpost action card
//outpost = draw 3 not 5 cards. get an extra turn. no more than 2 turns.
//outpost is card number 23

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"

int main(){
	//initialize game
	int seed = time(NULL) % 5000;
	srand(seed);
	struct gameState *gS = malloc(sizeof(struct gameState));
	int k[10] = {adventurer, council_room, feast, gardens, mine , remodel, smithy, village, baron, great_hall};
	int numPlayers = 0;
	int p = 0;				//current player
	
	int outpostFlag = 0;
	
	int tF = 0;				//count of failed tests

	int testNum = 1000;
	int i = 0;

	//run testNum tests
	for(i = 0; i < testNum; i++){
		numPlayers = rand() % 3 + 2;	//2, 3 or 4 players
		initializeGame(numPlayers, k, seed, gS);
		p = rand() % numPlayers;		//pick random player
		gS->whoseTurn = p;
		
		outpostFlag = 1;
		
		//call card function or cardEffect
		cardEffect(23, 0, 0, 0, gS, 0, 0);
		if(outpostFlag != gS->outpostPlayed){
			printf("FAIL. Flag = %d; Expected Flag = %d\n", gS->outpostPlayed, outpostFlag);
			tF++;
		}
		endTurn(gS);

		if(p != gS->whoseTurn){
			printf("FAIL. Turn = %d; Expected Turn = %d\n", gS->whoseTurn, p);
			tF++;
		}
		if(gS->handCount[p] != 3){
			printf("FAIL. Expected count = 3\n");
			tF++;
		}
		if(gS->outpostPlayed != 1){
			printf("FAIL. Expected outpost flag set.\n");
			tF++;
		}
	}
	
	free(gS);
	printf("All tests completed. Tests failed = %d\n", tF);
	return 0;
}